.widget-box
  .widget-title
    span.icon: i.icon-user
    h5 用户属性管理

  .widget-content
    table.table
      tr
        th style="width: 200px;" 属性名
        th 启用

      -  @properties.each do |p|
        tr
          td = p.name
          td
            = check_box_tag 'user_property_checkbox', p.id, p.opened?, :class => "user_property_checkbox"
            span.flash

    br
    = form_tag properties_path, :class => "form-inline", :method => "post"
      .control-group
        label.control-label for="new_organ_id" 添加自定义属性:
        .controls          
          input name="property[name]" type="text" class="form-control" placeholder="属性名"
          .help-block 示例： 家庭地址，出生地
      button type="submit" class="btn btn-primary" 新增

javascript:
  $(function(){
    $(".user_property_checkbox").click(function(){
      var checkbox = $(this);
      if(checkbox.attr("checked") == "checked"){
        checkbox.removeAttr("checked");
      }else{
        checkbox.attr("checked", "checked");
      }
      var flash = checkbox.siblings(".flash")
      $.get( ("/properties/" + checkbox.val() + "/edit?checked=" + (checkbox.attr("checked") == "checked") ),
      function(data){
        flash.html(data).show()
        setTimeout(function(){
          flash.fadeOut("hide");
        }, 1000);
      }).fail(function(){
        checkbox.siblings(".flash").html("服务器错误").show().fadeOut("hide");
      });
    });
  })